<template>
	<view class="body">
		<view class="p1">
			
		收件人:	<input type="text" value="" v-model="list.name" />
		</view>
		
		<view class="p1">
			电话:	<input type="text" value="" v-model="list.tel" />
		</view>
		
		<view class="p1">
			
			所在地址:	<input type="text" value="" v-model="list.cityStr" />
		</view>
		
		<view class="p1">
		
			详细地址:	<input type="text" value="" v-model="list.cityBak" />
		</view>
		
		
		<view class="baocun" @tap="baocun">
			保存
		</view>
		
		<view class="del" @tap="del">
			删除
		</view>
	</view>
</template>

<script>
	import{update}from "../../../../util/user/xiugai.js"
	import{detail}from "../../../../util/user/bianji.js"
	import{del}from "../../../../util/user/del.js"
	export default {
		data() {
			return {
				list:{},
				list2:""
			};
		},
		methods:{
			
		async	del(){
			
				var  val = await del({
					id:this.list.id
				})
				uni.redirectTo({
					url:`../address`
				})
			},
			
		async baocun(){
				var res = await update({
					id:this.list.id,
					tag:this.list.tag,
					userId:this.list2,
					cityCode:this.list.cityCode,
					provinceStr:this.list.provinceStr,
					cityStr:this.list.cityStr,
					areaStr:this.list.areaStr,
					cityBak:this.list.cityBak,
					tel:this.list.tel,
					name:this.list.name,
					isUse:this.list.isUse,
					region_arr:this.list.region_arr,
					
				})
				console.log(res)
				
				
				uni.navigateTo({
					url:`../address`
				})
			}
		},
onLoad(val) {
	this.ida=val.id
}		,
		
	async onShow(val) {
		var value2 = uni.getStorageSync("data");
		this.list2 = value2.id
	console.log(value2.id)
			uni.setNavigationBarTitle({
				title: '编辑',
			
			});
			uni.setNavigationBarColor({
			
				frontColor: '#ffffff',
				backgroundColor: ' #354E44',
				animation: {
					duration: 400,
					timingFunc: 'easeIn'
				}
			})
			
			var res = await detail({
				id:this.ida,
			})
			console.log(res)
			this.list = res.data.data
		
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		background-color: #F1ECE7;
		width: 100%;
		height: 100vh;
		overflow: hidden;
	}
	
	.p1{
		display: flex;
	}
	
	.baocun{
		width: 300rpx;
		height: 100rpx;
		margin: 0 auto;
		margin-top: 100rpx;
		text-align: center;
		line-height: 100rpx;
		background-color: yellow;
	}
	
	.del{
		width: 300rpx;
		height: 100rpx;
		margin: 0 auto;
		margin-top: 100rpx;
		text-align: center;
		line-height: 100rpx;
		background-color: blue;
		color: #FFFFFF;
	}
</style>
